<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover" />
	<title>Person</title>
</head>
<body>
<script>
// // 语法糖
// class Person {
// 	constructor(name, age) {
// 		this.name = name;
// 		this.age = age
// 	}
//
// 	run() {
// 		console.log(`${ this.name }在跑步`)
// 	}
// }


const Person = function (name, age) {
	this.name = name;
	this.age = age
	// this.run = new Function('console.log(`${ this.name }在跑步`)')
};

// Person.prototype.run = new Function('console.log(`${ this.name }在跑步`)')
Person.prototype.run = new Function('console.log(`${ this.name }在跑步`)')

const person1 = new Person('董锐', 18)
const person2 = new Person('亢旭明', 19)

person1.run();
person2.run();

console.log(person1.run === person2.run)

// 什么可以改变 this 的指向?
// console.log(`Person.prototype------`, Person.prototype)  // { ... }
// Person.prototype.run(); // this.name -> undefined
// console.log(`Person.prototype.run------`, Person.prototype.run)
// console.log('1', person1.__proto__.__proto__.__proto__.__proto__)
Person.prototype.run.call({ name: 'tom' });
</script>
</body>
</html>
